<template>
  <div>
    <el-dialog
      v-model="dialogVisible"
      title="商品详情"
      width="50%"
      destroy-on-close
    >
      <el-form :model="form">
        <el-form-item>
          <wangEditor v-model="form.content"></wangEditor>
        </el-form-item>
        <template #footer>
          <div class="dialog-footer">
            <el-button @click="dialogVisible = false">取消</el-button>
            <el-button type="primary" @click="submitOk">确定</el-button>
          </div>
        </template>
      </el-form>
    </el-dialog>
  </div>
</template>

<script setup>
import { ref } from "vue";
import { editGoodsFn, getGoodsInfoById } from "@/api/goods.js";
// import wangEditor from "@/components/wangEditor.vue"
const dialogVisible = ref(false);
const form = ref({
  content: "",
});

const submitOk =async () => {
  console.log(goodsId.value,form.value);
  // const res = await editGoodsFn(goodsId.value,form.value)
};
// 共享弹窗打开功能
const goodsId = ref();
const openDialog = async (row) => {
  goodsId.value = row.id;
  const res = await getGoodsInfoById(goodsId.value);
  if (res.msg && res.msg !== "ok") return;
  form.content = res.data.content;
  dialogVisible.value = true;
};
defineExpose({
  openDialog,
});
</script>

<style lang="less" scoped></style>
